package com.musicsonar.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.view.Menu;
import android.view.MenuItem;

public class PreferencesActivity extends PreferenceActivity{

	private static PreferencesActivity me;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);

		me = this;

		PreferenceCategory preferenceCategory = (PreferenceCategory)findPreference("accounts");
		Preference google = new Preference(me);
		google.setKey("account_name");
		google.setTitle(R.string.preferences_google_account_title);
		google.setSummary(R.string.preferences_google_account_summary);
		preferenceCategory.addPreference(google);

		Preference facebook = new Preference(me);
		facebook.setKey("access_token");
		facebook.setTitle(R.string.preferences_facebook_account_title);
		facebook.setSummary(R.string.preferences_facebook_account_summary);
		preferenceCategory.addPreference(facebook);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(Menu.NONE, 0, 0, getText(R.string.menu_btn_return_main)).setIcon(R.drawable.ic_menu_save);
		return super.onCreateOptionsMenu(menu);
	}

	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case 0:
				startActivity(new Intent(this, MusicSonarActivity.class));
				return true;
		}
		return false;

	}

}